﻿Imports NHibernate
Imports NHibernate.Criterion
Imports TodoMicroSolutionPackV1.productos.dal.dto
Imports TodoMicroSolutionPackV1.dal.dao
Namespace productos.dal.dao
    Public Class precioDAO
        Inherits GenericNHibernateDAO(Of precio, Integer)
        Public Function getPrecioPorLista(ByVal listId As Integer, ByRef producto As producto) As precio
            Dim criteria As ICriteria = session.CreateCriteria(Of precio)()
            criteria.Add(Expression.Eq("producto", producto))
            criteria.Add(Expression.Eq("lista_id", listId))

            Return criteria.UniqueResult
        End Function
        Public Function getPrecioDefault(ByRef producto As producto) As precio
            Return getPrecioPorLista(0, producto)
        End Function
        Public Sub New(ByRef session As ISession)
            MyBase.New(session)
        End Sub
    End Class
End Namespace